import instance from '../axios_config'

const get_twomenus = async (url: string) => {
  const Data = await instance.get(url)
  return Data.data
}

const add_twomenus = async (url: string, data: any) => {
  data.roles = data.roles.split(',')
  const Data = await instance.post(url, data)
  return Data.data
}

const delete_twomenu = async (url: string, id: string) => {
  const path = url + '/' + id + '/'
  const Data = await instance.delete(path)
  return Data.data
}

const edit_twomenu = async (url: string, data: any) => {
  if (!Array.isArray(data.roles)) {
    data.roles = data.roles.split(',')
  }
  const path = url + '/' + data.id + ' /'
  const Data = await instance.put(path, data)
  return Data.data
}
export default {
  get_twomenus,
  add_twomenus,
  delete_twomenu,
  edit_twomenu
}
